package com.ultrapower.request;

import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Scan;
import com.ultrapower.hbase.HbaseConfigurationFactory;
import com.ultrapower.hbase.HbaseConnectionFactory;
import com.ultrapower.hbase.HbaseTemplate;
import com.ultrapower.hbase.HbaseUtil;

/**
 * 
 * @author wangy
 *
 */
public abstract class BaseRequest {
	//agentID
	protected final String agentId="UASId120.15";
	protected String applicationName = "UASName120.15";
//	protected long from=1532597284123L;
//	protected long to=1532597173000L;
	protected long from=1532681282546L;
	protected long to=  1532683128546L;
	protected long timestamp=1532597384123L;
	protected long startTime=1532501015399L;
	
	protected short srviceTypeCode = 1010;
	
	private HbaseTemplate hbaseTemplate;
	protected static final int MAX_SCAN_CACHE_SIZE = 256;
	protected static final int SCANNER_CACHING = 20;

	/**
	 * 初始化-仅测试
	 */
	public BaseRequest() {
		hbaseTemplate = new HbaseTemplate();
		HbaseConfigurationFactory config = new HbaseConfigurationFactory();
		HbaseConnectionFactory con = new HbaseConnectionFactory(config.getHbaseConfig());
		hbaseTemplate.setTableFactory(con);
	}

	abstract void execute();

	/**
	 * 
	 * @param tableName
	 * @return
	 */
	protected TableName getTableName(String tableName) {
		return HbaseUtil.getTableName(tableName);
	}

	protected abstract Scan createScan();
	public HbaseTemplate getHbaseTemplate() {
		return hbaseTemplate;
	}
	
}
